package com.cristina.attention.publisher;

import com.cristina.attention.annotation.SyncChat;
import com.cristina.attention.domain.Chat;
import com.cristina.attention.event.SyncChatEvent;
import com.cristina.attention.utils.AttentionCommon;
import com.cristina.attention.utils.SpringContextHolder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author by superman
 */
public class SyncChatPublisher {

    /**
     * 如何做到固定每 50 条消息同步一次? 已经同步的消息如何删除? 是否需要记录已经读取的最后一个元素的下标
     *
     * @param chat
     * @param syncChat
     */
    public static void publishEvent(Chat chat, SyncChat syncChat) {
        chat.setChatType(syncChat.value());
        List<Object> list = new ArrayList<>();
        list.add(chat);
        SpringContextHolder.publishEvent(new SyncChatEvent(list));
    }
}
